package com.declare;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.custom.MySimpleAdapter;
import com.mode.DeskObj;
import com.mode.History;
import com.mode.MenuListDataObj;
import com.mode.MenuObj;
import com.mode.SelectedMenuObj;
import com.mode.SelectedProduct;
import com.model.AllDomain;
import com.model.Category;

import android.R.integer;
import android.app.Application;

public class Declare extends Application {
	public MenuListDataObj menuListDataObj;
	public ArrayList<DeskObj> deskList;
	public ArrayList<HashMap<String, Object>> deskHashMaps;
	public DeskObj curDeskObj;
	public History history;
	
	public MenuListDataObj getMenuListDataObj() {
		return menuListDataObj;
	}

	public void setMenuListDataObj(MenuListDataObj menuListDataObj) {
		this.menuListDataObj = menuListDataObj;
	}
	public History getHistory() {
		return history;
	}

	public void setHistory(History history) {
		this.history = history;
	}

	public void SyncMenuList()
	{
		HashMap<String, SelectedMenuObj> menuMap=new HashMap<String, SelectedMenuObj>();
		HashMap<String, List<SelectedMenuObj>> dicMenusHashtable=curDeskObj.selectedProduct.dicMenusHashtable;
		Set<String> strSet=dicMenusHashtable.keySet();
		Iterator iterator;
		for(iterator=strSet.iterator();iterator.hasNext();)
		{
			String strKeyString=(String)iterator.next();
			List<SelectedMenuObj> menuList=dicMenusHashtable.get(strKeyString);
			Iterator iterator2;
			for(iterator2=menuList.iterator();iterator2.hasNext();)
			{
				SelectedMenuObj menuObj=(SelectedMenuObj)iterator2.next();
				String sidString=menuObj.getId();
				menuMap.put(sidString, menuObj);
			}
		}
		
		List<SelectedMenuObj> menulist1=menuListDataObj.getMenuObjs();
		Iterator iterator3;
		for(iterator3=menulist1.iterator();iterator3.hasNext();)
		{
			SelectedMenuObj menuObj=(SelectedMenuObj)iterator3.next();
			String idString=menuObj.getId();
			if(menuMap.containsKey(idString))
			{
				menuObj.setCount(menuMap.get(idString).getCount());
				menuObj.setTotalPrice(menuMap.get(idString).getTotalPrice());
			}
		}
		
	}
	public void SyncDeskList()
	{
		int id=curDeskObj.getId();
		Iterator iterator;
		for(iterator=deskList.iterator();iterator.hasNext();)
		{
			DeskObj deskObj=(DeskObj)iterator.next();
			if(deskObj.getId()==id)
			{
				deskObj.setSelect(curDeskObj.isSelect());
				break;
			}
		}
	}
}
